package uvt.gui.mainframe.subpanel.addsss;

import java.awt.Component;

import javax.swing.JTextField;

import uvt.database.Database;
import uvt.database.SelectOperations;
import uvt.gui.mainframe.object.AutoCompleteTextField;
import uvt.gui.mainframe.object.observer.Observer;

public class StreetNameTextField extends JTextField implements Observer {
	
	private AutoCompleteTextField autoComplete;
	
	public StreetNameTextField() {
		setAlignmentX(Component.CENTER_ALIGNMENT);
		setAlignmentY(Component.CENTER_ALIGNMENT);
		setColumns(20);
		autoComplete = new AutoCompleteTextField();
		((SelectOperations)Database.getInstace()).selectStreetName(autoComplete.getItems());
		autoComplete.setupAutoComplete(this);
	}

	public void update() {
		autoComplete.getItems().clear();
		((SelectOperations)Database.getInstace()).selectStreetName(autoComplete.getItems());
		autoComplete.setupAutoComplete(this);
	}
	
	public AutoCompleteTextField getAutoComplete() {
		return autoComplete;
	}

}